﻿<section class="container-fluid case" style="background-color: white;">
    <div class="data-tool clearfix">
        <form class="form-horizontal m15_t" id="form">
            <div class="tab-content">
                <input type="hidden" id="Id" name="Id" value="1">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="wd100 control-label"><span class="WdateFmtErr">*</span>单据编号：</label>
                        <div class="wd400 m15_l">
                            <input class="form-control input-xs" name="orderId" type="text" value="@(ViewBag.OrderId)" data-options="required:true,prompt:'单据编号'">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label m15_l"><span class="WdateFmtErr">*</span>库存：</label>
                        <div class="input-group wd400 m15_l">
                            <input class="form-control" type="hidden" name="inventoryId" maxlength="20" autocomplete="off" />
                            <input class="form-control" type="text" name="orderId" maxlength="20" placeholder="请选择出库单" autocomplete="off" disabled />
                            <span class="input-group-addon" style="margin-left:20px;">
                                <i data-modal="/Module/Inventory" data-title="库存" data-width="1000" data-height="560" class="glyphicon glyphicon glyphicon-align-justify"></i>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="wd100 control-label">备注：</label>
                        <div class="wd400 m15_l">
                            <input class="form-control" type="text" name="remark" maxlength="40" autocomplete="off" placeholder="长度必须介于 0 和 40 之间">
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</section>

@section footerScript{
    <script type="text/javascript">
        function Tip_success(word) {
            Topro.UI.Tip_success(word);
        }

        function set(obj) {
            $("input[name='inventoryId']").val(obj.inventoryId);
            $("input[name='orderId']").val(obj.orderId);
        }

        function save() {
            //出库
            var stockOut = {};
            //订单号
            stockOut.orderId = $("input[name='orderId']").val();
            //入库订单编号
            stockOut.inventoryId = $("input[name='inventoryId']").val();
            //订单类型
            stockOut.orderType = $("input[name='orderType']").is(':checked') == true ? 40 : 20;
            //预叠类型
            stockOut.preType = $("select[name='preType']").val();
            //备注
            stockOut.remark = $("input[name='remark']").val();

            Topro.UI.DialogBox({
                id: 'dialog_confirm',
                title: '操作',
                parent: true,
                lock: true,
                fixed: true,
                icon: 'question',
                padding: '20px 15px 20px 10px',
                ok: function () {
                    Topro.UI.Ajax({
                        type: "POST",
                        url: "/StockOut/Save",
                        data: {
                            stockOut: stockOut
                        },
                        success: function (res) {
                            if (res.success) {
                                Topro.UI.DialogOpener().Tip_success("操作成功！");
                                Topro.UI.DialogOpener().Out.doSearch();
                                Topro.UI.CloseDialog();
                            } else {
                                Topro.UI.Tip_warning("操作失败！" + res.message);
                            }
                        },
                        error: function (e) {
                            Topro.UI.Tip_warning("操作失败！请查看网络，请重试。");
                        }
                    });
                },
                width: '200px',
                content: '您确认要操作出库?',
                cancel: function () {

                }
            });
        }

        function doSearch() {
            Topro.UI.Pager(".paging", { pageSize:5,ajax: { url: '@Url.Action("InventoryQuery", "Inventory")' } });
        }
    </script>
}
